import { Form, Input, Button } from 'antd'
import { useEffect } from 'react'
function RefMD(props) {
  const [form] = Form.useForm()
  useEffect(() => {
    form.setFieldsValue(props.refdata)//用于回显给他赋值
  }, [])
  function onFinish(values) {
    props.setRefdata(values)
  }
  function onValuesChange(values) {
    props.setRefdata({
      ...props.refdata,
      ...values
    })
  }
  return (
    <>
      <Form
        name="basic"
        form={form}
        labelCol={{ span: 12 }}
        wrapperCol={{ span: 12 }}
        style={{ maxWidth: '60%' }}
        onFinish={onFinish}
        onValuesChange={onValuesChange}
        autoComplete="off"
      >
        <Form.Item
          label="名称"
          name="username" >
          <Input />
        </Form.Item>
        <Form.Item
          label="密码"
          name="password" >
          <Input />
        </Form.Item>
        <Form.Item label={null}>
          <Button type="primary" htmlType="submit">  保存 </Button>
        </Form.Item>
      </Form>
    </>
  )
}
export default RefMD
